package com.bdqn.Interceptor;

import com.bdqn.common.AuthorizationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置（使用Shiro之后可以不用）
 *
 * @author LILIBO
 * @since 2021-12-08
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    private String[] pathPatterns = {"/**"}; // 拦截路径规则
    private String[] excludePathPatterns = {"/","/home/**","/home/login2","/system/login","/system/get_cpacha","/statics/**","/system/*","/pay","/error","/home/account/**","/center/index","//statics/**"}; // 排除路径规则
//    private String[] excludePathPatterns = {"/","/home/login2","/admin/**", "/system/*", "/system/get_cpacha", "/statics/**","/home/account/**"}; // 排除路径规则

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthorizationInterceptor()) // 注册拦截器
                .addPathPatterns(pathPatterns) // 添加路径规则
                .excludePathPatterns(excludePathPatterns); // 添加排除路径规则
    }
}
